<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改广告位管理')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-adplace-edit" th:object="${advertisingPlace}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">应用ID：</label>
                <div class="col-sm-8">
                    <select name="appId" class="form-control m-b" th:with="type=${@dict.getType('kkad_app_id')}" style="pointer-events: none;">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{appId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" th:with="type=${@dict.getType('kkad_ad_type')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">宽：</label>
                <div class="col-sm-8">
                    <input name="width" th:field="*{width}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">高：</label>
                <div class="col-sm-8">
                    <input name="height" th:field="*{height}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">说明：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">启用：</label>
                <div class="col-sm-8">
                    <label class="toggle-switch switch-solid"/>
                    <input type="checkbox" id="status" th:checked="${advertisingPlace.status == 0 ? false : true}">
                    <span></span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开启第三方：</label>
                <div class="col-sm-8">
                    <label class="toggle-switch switch-solid"/>
                    <input type="checkbox" id="openThird" th:checked="${advertisingPlace.openThird == 0 ? false : true}">
                    <span></span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">第三方类型：</label>
                <div class="col-sm-8">
                    <select name="thirdType" class="form-control m-b" th:with="type=${@dict.getType('kkad_third_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{thirdType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">第三方屏蔽策略：</label>
                <div class="col-sm-8">
                    <select name="shieldStrategy" class="form-control m-b" th:with="type=${@dict.getType('kkad_shield_strategy')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{shieldStrategy}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">屏蔽后第三方类型：</label>
                <div class="col-sm-8">
                    <select name="shieldThirdType" class="form-control m-b" th:with="type=${@dict.getType('kkad_third_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{shieldThirdType}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "kkad/adplace";
        $("#form-adplace-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	var data = $('#form-adplace-edit').serializeArray()
            	var status = $("input[id='status']").is(':checked') == true ? 1 : 0;
            	data.push({"name": "status", "value": status});
            	var openThird = $("input[id='openThird']").is(':checked') == true ? 1 : 0;
            	data.push({"name": "openThird", "value": openThird});
                $.operate.save(prefix + "/edit", data);
            }
        }

    </script>
</body>
</html>